package cn.com.blogonline;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class CheckUnameAction extends HttpServlet {
    
	public void init(ServletConfig config) throws ServletException {
    }
    
    /*
     *  处理<GET> 请求方法.
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    	//设置接收信息的字符集
    	request.setCharacterEncoding("UTF-8");
    	//接收浏览器端提交的信息
		String uname = request.getParameter("uname");
		
		//设置输出信息的格式及字符集        
        response.setContentType("text/xml; charset=UTF-8");
        response.setHeader("Cache-Control", "no-cache");
        //创建输出流对象
        PrintWriter out = response.getWriter();
        /*
         *检查用户名，并输出结果 
         */
		DbOperate	db=new DbOperate();
		Blog blog=db.getBlog(uname);
		if (blog==null) {
			out.println("0");
		}else {
			out.println("1");
		}
		out.close();
    }
}
